package cn.itsource.basic.jobtask;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.Schedules;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
* 定时提醒类
* @author wangcp
* @date 2021/05/08 18:04
**/
@Component
public class TimingRemindTask {


    @Autowired
    TaskService taskService;

    /**
     * 没10秒执行一下
     */
    @Schedules({@Scheduled(cron = "0/5 * * * * ?")})
    public void remindTask(){

        try {
            taskService.executeRemindMessage();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        /*       SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        System.out.println("执行定时任务了,执行时间为：" + sdf.format(new Date()));
        System.out.println(Thread.currentThread().getName());*/
    }
}